import React, { Component } from "react";
import axios from "axios";
import "./App.css";
export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      data: [],
    };
    this.ref = React.createRef();
    this.dianji = this.dianji.bind(this);
  }
  static getDeriveStateFromProps(props, state) {
    return null;
  }
  dianji = () => {
    console.log("执行点击");
  };
  render() {
    return (
      <div>
        <input type="text" ref={this.ref} name="" id="" />
        <div>
          {this.state.data.map((v) => {
            return <img src={v.image_src} alt="" />;
          })}
        </div>
        <div className="da" id="da">
          <div className="xiao"></div>
        </div>
      </div>
    );
  }
  componentDidMount() {
    // 1. 请求数据
    axios
      .get("https://www.linweiqin.cn/api/public/v1/home/swiperdata")
      .then((res) => {
        console.log(res);
        this.setState({
          data: res.data.message,
        });
      });
    // todo redux subscribe 订阅数据
    // 3. 注册事件
    document.getElementById("da").scroll(function (e) {
      console.log(e);
    });
  }
}
